package patrol.mobile.com.mobilepatrol.activity.security.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.dl7.recycler.adapter.BaseQuickAdapter;
import com.dl7.recycler.adapter.BaseViewHolder;

import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.activity.security.emergency.ZHCXEmergencyProtectCheckActivity;
import patrol.mobile.com.mobilepatrol.bean.ProtectCollectionBean;

/**
 * Created by admin on 2018/9/9.
 */

public class ZHCXEmergencyProtectCollectionAdapter extends BaseQuickAdapter<ProtectCollectionBean> {


    public ZHCXEmergencyProtectCollectionAdapter(Context context) {
        super(context);
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.item_zhcx_emergency_protect_collection_list;
    }

    @Override
    protected void convert(final BaseViewHolder holder, final ProtectCollectionBean item) {

        holder.setText(R.id.tv_num, (holder.getLayoutPosition() + 1) + "");
        holder.setText(R.id.tv_orgName, item.getOrgName());
        holder.setText(R.id.tv_inspectionName, item.getInspectionName());
        holder.setText(R.id.tv_duty, item.getDuty() + "值班");
        holder.setText(R.id.tv_inspectionDate, item.getInspectionDate());
        holder.setText(R.id.tv_situation, item.getSituation().equals("1") ? "在岗" : "不在岗");
        if (!item.getSituation().equals("1")){
            holder.setBackgroundRes(R.id.tv_situation,R.drawable.shape_rect_red);
            holder.setTextColor(R.id.tv_situation,mContext.getResources().getColor(R.color.white));
        }else{
            holder.setBackgroundRes(R.id.tv_situation,0);
            holder.setTextColor(R.id.tv_situation,mContext.getResources().getColor(R.color.black_light));
        }

        holder.setOnClickListener(R.id.rl_root, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, ZHCXEmergencyProtectCheckActivity.class);
                intent.putExtra("id", item.getId());
                mContext.startActivity(intent);
            }
        });

    }
}
